﻿package model.drawPanel;

import java.util.ArrayList;

import model.drawPanel.entitys.Entity;

public class DrawOrder_Size extends DrawOrder{
	private String zoomMsg;
	private int xmove;
	private int ymove;
	private int xchange,ychange;
	public DrawOrder_Size(int id,String zoomMsg, int xmove ,int ymove) {
		super(id);
		this.zoomMsg = zoomMsg;
		this.xmove = xmove;
		this.ymove = ymove;
	}
	@Override
	public void execute(ArrayList<Entity> entitylist) {
		for(Entity en:entitylist){
			if(en.getId()==id){
				if(xchange!=0 || ychange != 0){
					en.changeSize(zoomMsg, xchange, ychange);
				}else{
					en.changeSize(zoomMsg, xmove, ymove);
				}
				break;
			}
		}
		xchange =0;
		ychange =0;
	}
	@Override
	public void undo(ArrayList<Entity> entitylist) {
		for(Entity en:entitylist){
			if(en.getId()==id){
				en.changeSize(zoomMsg, -xmove, -ymove);
				break;
			}
		}
		
	}
	
	@Override
	public void change(int x, int y) {
		xchange = x;
		ychange = y;
		xmove = xmove +x;
		ymove =ymove +y;
		
	}
	

}
